rsync错误二则、排错过程及解决办法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
#
#created by zhaopeiwu @ 2015-04-20
#FOR control the size of error log of apache
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/apache2/bin:/usr/local/mysql/bin
export PATH
log_path="/usr/local/apache2/logs/"
log_size=`du -s $log_path/error_log|cut -f 1`
if [ $log_size -gt 100000 ];
then
mv $log_path/error_log $log_path/error_log_`date +%Y%m%d`;
touch $log_path/error_log;
fi
num_del=`ls -t $log_path/error*|wc -l`
if [ $num_del -gt 4 ];
then
ls -t $log_path/error*|tail -$[$num_del-2]|xargs -i rm -f {} 2 > /dev/null
fi
exit 0